package org.springcloud.wisdom.spring_01_canteen.loginmsg.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springcloud.wisdom.spring_01_canteen.login.entity.Student;
import org.springcloud.wisdom.spring_01_canteen.loginmsg.dao.MyStudentDao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StudentSeriveImp implements IStudentService {
    @Autowired
    MyStudentDao myStudentDao;
    @Override
    public Boolean updateStudent(Student student) {
        if (student.getSid() == null) {
            return false;
        }
        return myStudentDao.update(student) > 0;
    }

    @Override
    public IPage<Student> getStudentPage(int currentPage, int size) {
        Page<Student> pageRequest = new Page<>(currentPage, size);
        IPage<Student> getStudentPage = myStudentDao.selectStudentPage(pageRequest);
        return getStudentPage;
    }

    @Override
    public Student getAStudent(String sid) {
        return myStudentDao.selectAStudent(sid);
    }
}
